/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package deatax.card;

import deatax.GameData;
import deatax.Player;
import deatax.Tile;
import java.util.ArrayList;

/**
 * arg[0] is the flat land tax amount per owned land tile
 * arg[1] is the flat property tax per owned improvement
 * @author pson
 */
public class CardTerrainTax extends CardEffect {

    @Override
    public void run(GameData data, String[] args) {

        ArrayList<Player> players = new ArrayList<Player>();
        if (args[0].equals("All")) {
            players.addAll(data.getRoster().getPlayers());
        } else if (args[0].equals("Self")) {
            players.add(data.getCurrentPlayer());
        } else if (args[0].equals("Other")) {
            players.addAll(data.getRoster().getPlayers());
            players.remove(data.getCurrentPlayer());
        }
        
        int per_unit = Integer.parseInt(args[1]);
        for (Player p : players) {
            int total = 0;
            for (Tile t : p.getTiles()) {
                total += per_unit;
                p.addResource(data.getGame().getResource("Money"), per_unit);
            }

            if (per_unit > 0) {
                data.getGui().addMessage(p, "Receives $" + total + " land tax");
            } else {
                data.getGui().addMessage(p, "Pays $" + (-total) + " land tax");
            }
        }
    }
}
